package com.zy.thread.ticket;

/**
 * @Author Gong
 * @Description
 * @dATE 2021/12/13 14:37
 **/
public class ThreadWindowOne extends Thread{
    private static int tickets=100;  //总票数
    @Override
    public void run() {
        while(true){
            if (tickets>0) {
                //

                tickets = tickets;
                System.out.println(Thread.currentThread().getName()+"正在售票...票号为："+tickets);//
                try {
                    sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                tickets= tickets -1;

            }
            else{
                break;
            }
        }
    }

    public static void main(String[] args) {
        ThreadWindowOne one=new ThreadWindowOne();
        ThreadWindowOne two=new ThreadWindowOne();
        ThreadWindowOne three=new ThreadWindowOne();
        one.start();
        two.start();
        three.start();

    }
}
